ComponentOne PdfViewer for UWP
Key Features / Loading Documents from the Web
In This Topic
    Loading Documents from the Web
    In This Topic

    To load a file from the Web you must first download it to your application using an asynchronous request object such as HttpClient. Then you simply pass the resulting stream to the LoadDocument method or LoadDocumentAsync method. The following code snippet example uses an HTTP request:

    C#
    Copy Code
    private async void LoadDocument()
    {
         // load file from the Web
         HttpClient client = new HttpClient();
         string url = “http://cdn.componentone.com/files/win8/Win8_UXG_RTM.pdf”;
        
        try
        {
           var stream = await client.GetStreamAsync(new Uri(url, UriKind.Absolute));
           pdfViewer.LoadDocument(stream);
        }
        catch
        {
           var dialog = new MessageDialog("There was an error attempting to download the document.");
           dialog.ShowAsync();
        }
    }